import 'dart:convert';

import 'package:lib_common/lib_common.dart';

class BannerInfo {
  BannerInfo({
    String? id,
    String? title,
    String? slogan1,
    String? slogan2,
    String? image1,
    String? image2,
    String? gameDetailsId,
    String? jumpUrl,
    num? type,
    GameInfo? gameDetails,
  }) {
    _id = id;
    _title = title;
    _slogan1 = slogan1;
    _slogan2 = slogan2;
    _image1 = image1;
    _image2 = image2;
    _gameDetailsId = gameDetailsId;
    _jumpUrl = jumpUrl;
    _type = type;
    _gameDetails = gameDetails;
  }

  BannerInfo.fromJson(dynamic json) {
    _id = json['_id'];
    _title = json['title'];
    _slogan1 = json['slogen1'];
    _slogan2 = json['slogen2'];
    _image1 = json['image1'];
    _image2 = json['image2'];
    _gameDetailsId = json['game_details_id'];
    _jumpUrl = json['jumpurl'];
    _type = json['btype'];
    _gameDetails = GameInfo.fromJson(json['game_details']);
  }

  String? _id;
  String? _title;
  String? _slogan1;
  String? _slogan2;
  String? _image1;
  String? _image2;
  String? _gameDetailsId;
  String? _jumpUrl;
  num? _type;
  GameInfo? _gameDetails;

  BannerInfo copyWith({
    String? id,
    String? title,
    String? slogan1,
    String? slogan2,
    String? image1,
    String? image2,
    String? gameDetailsId,
    String? jumpUrl,
    num? type,
    GameInfo? gameDetails,
  }) =>
      BannerInfo(
        id: id ?? _id,
        title: title ?? _title,
        slogan1: slogan1 ?? _slogan1,
        slogan2: slogan2 ?? _slogan2,
        image1: image1 ?? _image1,
        image2: image2 ?? _image2,
        gameDetailsId: gameDetailsId ?? _gameDetailsId,
        jumpUrl: jumpUrl ?? _jumpUrl,
        type: type ?? _type,
        gameDetails: gameDetails ?? _gameDetails,
      );

  String? get id => _id;

  String? get title => _title;

  String? get slogan1 => _slogan1;

  String? get slogan2 => _slogan2;

  String? get image1 => _image1;

  String? get image2 => _image2;

  String? get gameDetailsId => _gameDetailsId;

  String? get jumpUrl => _jumpUrl;

  num? get type => _type;

  GameInfo? get gameDetails => _gameDetails;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['_id'] = _id;
    map['title'] = _title;
    map['slogen1'] = _slogan1;
    map['slogen2'] = _slogan2;
    map['image1'] = _image1;
    map['image2'] = _image2;
    map['game_details_id'] = _gameDetailsId;
    map['jumpurl'] = _jumpUrl;
    map['btype'] = _type;
    map['game_details'] = _gameDetails;
    return map;
  }

  @override
  String toString() {
    return jsonEncode(this).toString();
  }
}
